<?php

namespace App\Http\Requests\Strator;

use Illuminate\Foundation\Http\FormRequest;

class StoreStratorRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'strator_account'=>'required|alpha_num|min:6|max:30|unique:strators,strator_account',
            'strator_mobile'=>'sometimes|integer|min:10000000000|max:19999999999|unique:strators,strator_mobile',
            'strator_email'=>'sometimes|email|unique:strators,strator_email',
            'strator_password'=>'sometimes|string|min:8|max:20',
        ];
    }
    /**
     * Get the error messages for the defined validation rules.
     *
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'strator_account.required' => '账号为必填',
            'strator_account.alpha_num' => '账号只能包含字母和数字',
            'strator_account.min' => '账号长度要在6-30位之间',
            'strator_account.max' => '账号长度要在6-30位之间',
            'strator_account.unique' => '账号已存在',

            'strator_mobile.integer' => '手机号格式不正确',
            'strator_mobile.min' => '手机号格式不正确',
            'strator_mobile.max' => '手机号格式不正确',
            'strator_mobile.unique' => '此手机号已存在',

            'strator_email.email' => '邮箱格式不正确',
            'strator_email.unique' => '此邮箱已存在',

            'strator_password.string' => '密码必须为字符串类型',
            'strator_password.min' => '密码长度要在8-20位之间',
            'strator_password.max' => '密码长度要在8-20位之间',
        ];
    }
}
